package net.lab1024.sa.admin.module.business.erp.controller;


import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import net.lab1024.sa.admin.module.business.erp.domain.entity.MachineEntity;
import net.lab1024.sa.admin.module.business.erp.domain.form.add.MachineAddForm;
import net.lab1024.sa.admin.module.business.erp.domain.form.query.MachineQueryForm;
import net.lab1024.sa.admin.module.business.erp.domain.form.update.MachineUpdateForm;
import net.lab1024.sa.admin.module.business.erp.domain.vo.MachineVO;
import net.lab1024.sa.admin.module.business.erp.service.MachineService;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.nio.charset.Charset;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * 设备表 Controller
 *
 * @Author akita
 * @Date 2025-04-17 16:47:56
 * @Copyright akita
 */

@RestController
@Tag(name = "设备表")
public class MachineController {

    @Resource
    private MachineService machineService;


    @PostMapping("/machine/queryPage")
    public ResponseDTO<PageResult<MachineVO>> queryPage(@RequestBody @Valid MachineQueryForm queryForm) {




        return ResponseDTO.ok(machineService.queryPage(queryForm));
    }


    @PostMapping("/machine/add")
    public ResponseDTO<Long> add(@RequestBody @Valid MachineAddForm addForm) {
        return machineService.add(addForm);
    }


    @PostMapping("/machine/update")
    public ResponseDTO<String> update(@RequestBody @Valid MachineUpdateForm updateForm) {




        return machineService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author akita")
    @PostMapping("/machine/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return machineService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author akita")
    @GetMapping("/machine/delete/{docEntry}")
    public ResponseDTO<String> batchDelete(@PathVariable Long docEntry) {
        return machineService.delete(docEntry);
    }


    @GetMapping("/machine/info/{docEntry}")
    public ResponseDTO<MachineEntity> info(@PathVariable Long docEntry) {
        return machineService.info(docEntry);
    }

    @RequestMapping("/machine/SendWeight")
    public ResponseDTO<MachineEntity> SendWeight(String str) {

        return ResponseDTO.ok();
    }

}
